package com.rede.didiok.user.modulelist.pay.restapi;

import javax.annotation.Resource;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import com.rede.didiok.common.dto.pay.PayOrderDto;
import com.rede.didiok.common.enums.OrderStatusEnum;
import com.rede.didiok.common.enums.ResourceTypeEnum;
import com.rede.didiok.common.utils.ResultUtil;
import com.rede.didiok.user.modulelist.pay.service.PayOrderService;


/**
 * 支付服务API接口
 */
@RestController
@RequestMapping("/order")
@Api(value = "订单模块", tags = {"订单模块"})
public class PayOrderRestApi {

    @Resource
    private PayOrderService payOrderService;

    //    @FeignSecurity
    @ApiOperation(value = "获取订单列表", notes = "获取订单列表")
    @RequestMapping(value = "/getPageList", method = RequestMethod.POST)
    public String getPageList(@RequestBody PayOrderDto payOrderVO) {
        return ResultUtil.successWithData(payOrderService.getPageList(payOrderVO));
    }

    //    @FeignSecurity
    @ApiOperation(value = "获取我的订单列表", notes = "获取我的订单列表")
    @RequestMapping(value = "/listMyOrder", method = RequestMethod.POST)
    public String listMyOrder(@RequestBody PayOrderDto payOrderVO) {

        return ResultUtil.successWithData(payOrderService.listMyOrder(payOrderVO));
    }

    //    @FeignSecurity
    @ApiOperation(value = "获取我发起的活动下的订单列表", notes = "获取我发起的活动下的订单列表")
    @RequestMapping(value = "/myRankMember/order/list", method = RequestMethod.POST)
    public String listOrderOfMyRankMember(@RequestBody PayOrderDto payOrderVO) {

        return ResultUtil.successWithData(payOrderService.listOrderOfMyRankMember(payOrderVO));
    }

    //    @FeignSecurity
    @ApiOperation(value = "获取订单详情", notes = "获取订单详情")
    @RequestMapping(value = "/getOrderDetail", method = RequestMethod.POST)
    public String getOrderDetail(@RequestBody PayOrderDto payOrderVO) {

        return ResultUtil.successWithData(payOrderService.getOrderDetail(payOrderVO));
    }

    //    @FeignSecurity
    @ApiOperation(value = "活动主办方取消某人报名", notes = "活动主办方取消某人报名")
    @RequestMapping(value = "/organizerCancelOrder", method = RequestMethod.POST)
    public String organizerCancelOrder(@RequestBody PayOrderDto payOrderVO) {

        return ResultUtil.successWithData(payOrderService.organizerCancelOrder(payOrderVO));
    }

    //    @FeignSecurity
    @ApiOperation(value = "获取订单数量", notes = "获取订单数量")
    @RequestMapping(value = "/getPayOrderCount", method = RequestMethod.POST)
    public String getPayOrderCount(@RequestBody PayOrderDto payOrderVO) {
        return ResultUtil.successWithData(payOrderService.getPayOrderCount(payOrderVO));
    }


    @ApiOperation(value = "获取订单累积金额", notes = "获取订单累积金额")
    @RequestMapping(value = "/getPayOrderSumFee", method = RequestMethod.POST)
    public String getPayOrderSumFee(@RequestBody PayOrderDto payOrderVO) {
        return ResultUtil.successWithData(payOrderService.getPayOrderSumFee(payOrderVO));
    }

    @ApiOperation(value = "校验订单是否支付", notes = "校验订单是否支付")
    @RequestMapping(value = "/checkWhetherPay", method = RequestMethod.GET)
    public String checkWhetherPay(@RequestParam String productUid, @RequestParam(value = "orderUid", required = false) String orderUid) {
        return ResultUtil.successWithData(payOrderService.checkWhetherPay(productUid, orderUid));
    }

    @ApiOperation(value = "获取赞助订单列表", notes = "获取赞助订单列表")
    @RequestMapping(value = "/getSponsorOrderList", method = RequestMethod.POST)
    public String getSponsorOrderList(@RequestBody PayOrderDto payOrderVO) {
        payOrderVO.setResourceType(ResourceTypeEnum.SPONSOR.getType());
        payOrderVO.setOrderStatus(OrderStatusEnum.PaySuccess);
        return ResultUtil.successWithData(payOrderService.getPageList(payOrderVO));
    }
}
